from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QGroupBox
from PyQt5.QtCore import QEvent


class CustomGroupBox(QGroupBox):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setMouseTracking(True)  # 开启鼠标追踪
        # self.original_style = self.styleSheet()  # 保存原始样式

    def enterEvent(self, event):
        # 鼠标进入时的事件处理
        self.setStyleSheet("QGroupBox{background-color: rgba(187, 151, 53, 120);color: #56543e; font-size:15px;font-family:微软雅黑;font-weight:600;}")  # 取消背景透明
        super().enterEvent(event)

    def leaveEvent(self, event):
        # 鼠标离开时的事件处理
        self.setStyleSheet("QGroupBox{background-color: rgba(187, 151, 53, 50);color: #56543e; font-size:15px;font-family:微软雅黑;font-weight:600;}")  # 恢复原始样式
        super().leaveEvent(event)